#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int minSwaps(vector<int>& nums) {
        int sum = 0;
        for (auto e : nums) sum += e;
        int cur = 0;
        for (int i = 0; i < sum; i++)
            cur += nums[i];

        int Max = cur;
        int n = nums.size();
        for (int i = 1; i < n; i++)
        {
            cur += nums[(sum + i - 1) % n];
            cur -= nums[i - 1];
            Max = max(Max, cur);
        }

        return sum - Max;
    }
};